//
//  JBWMainNavView.m
//  JBWDSK
//
//  Created by 崔志伟 on 2018/7/30.
//  Copyright © 2018年 崔志伟. All rights reserved.
//

#import "JBWMainNavView.h"

@interface JBWMainNavView ()
@property (nonatomic,strong) UILabel  * backTitleLabel ;
@property (nonatomic,copy) void(^backNavBlock)(void) ;
@property (nonatomic,strong)   UIButton *backBtn  ;
@end
@implementation JBWMainNavView

- (instancetype)initWithFrame:(CGRect)frame
{
    if (self  = [super initWithFrame:frame]) {
        
        UIButton *backBtn = [[UIButton alloc]initWithFrame:CGRectMake(0, 0, 40, frame.size.height)];
        [backBtn setImage: GetImageNamed(@"sdk_ic_back") forState:UIControlStateNormal];
        [backBtn addTarget:self action:@selector(backBtnAction) forControlEvents:UIControlEventTouchUpInside];
        [self addSubview:backBtn];
        self.backBtn = backBtn;
        self.backTitleLabel = [[UILabel alloc]initWithFrame:CGRectMake(0, 0, frame.size.width, frame.size.height)];
        self.backTitleLabel.textColor = [UIColor whiteColor];
        self.backTitleLabel.font = [UIFont systemFontOfSize:18];
        self.backTitleLabel.textAlignment = NSTextAlignmentCenter;
        [self addSubview:self.backTitleLabel];
        UIView *line = [[UIView alloc]initWithFrame:CGRectMake(0, frame.size.height-1, frame.size.width, 1)];
        line.backgroundColor = [UIColor grayColor];
        [self addSubview:line];
        
    }
    return self;
}
- (void)setBackTitle:(NSString *)backTitle{
    _backTitle = backTitle;
    self.backTitleLabel.text = _backTitle;
}

- (void)setIsHideBackBtn:(BOOL)isHideBackBtn{
    _isHideBackBtn = isHideBackBtn;
    self.backBtn.hidden = isHideBackBtn;
}
- (void)backBtnAction{
    if (self.backNavBlock) {
        self.backNavBlock();
    }
}


+ (instancetype)showNavViewBackTitle:(NSString *)backTitle backNavBlock:(void(^)(void))backNavBlock{
    
    JBWMainNavView *navView = [[JBWMainNavView alloc]initWithFrame:CGRectMake(0, 0, JBW_PERSON_BG_VIEW_WIDTH-JBW_TABBAR_VIEW_WIDTH, 48)];
    navView.backTitle = backTitle;
    navView.backNavBlock = backNavBlock;
    return navView;
}









@end
